#-*-encoding=utf-8-*-
name=u'booking'
title=u'会议室预订记录'
description=u'None'
fields=(
    TextLineField(
        description='',
        title=u'会议主题',
        validation_exp=u'',
        write_condition=u'',
        size=30,
        default_value_exp=u'""',
        name=u'title'
),
    TextLineField(
        description='',
        title=u'部门',
        validation_exp=u'',
        write_condition=u'',
        size=18,
        default_value_exp=u'""',
        name=u'dept'
),
    SingleSelectField(
        title=u'会议室',
        vocabulary_exp=u'flowsettings["rooms"]',
        limit=4,
        default_value_exp=u'""',
        name=u'room'
),
    DateField(
        minutestep=5,
        description='',
        title=u'开始时间',
        showtime=True,
        validation_exp=u'',
        write_condition=u'',
        default_value_exp=u'datetime.datetime.today()',
        name=u'start'
),
    DateField(
        minutestep=5,
        description='',
        title=u'结束时间',
        showtime=True,
        validation_exp=u'',
        write_condition=u'',
        default_value_exp=u'datetime.datetime.today()',
        name=u'end'
),
    PersonSelectField(
        description='',
        title=u'主持',
        validation_exp=u'',
        multiple_selection=False,
        selectable_object='persononly',
        write_condition=u'',
        default_value_exp=u'',
        name=u'master'
),
    PersonSelectField(
        description='',
        title=u'记录人',
        validation_exp=u'',
        multiple_selection=False,
        selectable_object='persononly',
        write_condition=u'',
        default_value_exp=u'',
        name=u'writer'
),
    PersonSelectField(
        description='',
        title=u'参与人',
        validation_exp=u'',
        multiple_selection=True,
        selectable_object='persongroup',
        write_condition=u'',
        default_value_exp=u'None',
        name=u'attendee'
),
    TextField(
        rows=5,
        description='',
        title=u'资源',
        cols=10,
        validation_exp=u'',
        write_condition=u'',
        default_value_exp=u'""',
        name=u'resource'
),
    TextField(
        rows=5,
        description='',
        title=u'会议详细信息',
        cols=10,
        validation_exp=u'',
        write_condition=u'',
        default_value_exp=u'""',
        name=u'description'
),
    TextField(
        rows=5,
        description=u'记录现场的会议情况',
        title=u'会议情况报告',
        cols=10,
        validation_exp=u'',
        write_condition=u'',
        default_value_exp=u'""',
        name=u'report'
),
    TextField(
        rows=5,
        description='',
        title=u'审核意见',
        cols=10,
        validation_exp=u'',
        write_condition=u'',
        default_value_exp=u'""',
        name=u'review_comment'
),)

displayed_columns = [u'title', u'room', u'start', u'end']
fields_validation_script=ur"""# 检查开始结束时间
start = sheet['start']
end = sheet['end']
room = sheet['room']

if start >= end:
    return { 'start':'start should be later than end',
             'end':'end should be earlier than start',
            }

result = searchObjects(path=container,
object_provides=['zopen.flow.interfaces.IFlowSheet'],
                        subjects=(["Booked", room], 'allof'), start=(None, end),
                        end=(start, None))

for item in result:
    if item is not sheet:
        return { 'start':'this time span is not empty',
             'end':'this time span is not empty'
           }

return {}
"""
